// display.c
// 
// Program to list all of the .MPX files in the current directory or
// in a directory specified by the user
//
// tours de force: http://www.ducksarepeople.com/tdf
// Uncomment for debugging:
// #define DEBUG

#include <stdio.h>
#include "mpx_supt.h"
#include "display.h"


int display (char *folder)
{
  char buff[DISPLAY_BUFFER_SIZE];
  long file_size;
  int  SYS_OPEN_ERR = 0;
  int  SYS_GET_ERR = 0;
  int  SYS_CLOSE_ERR = 0;

  SYS_OPEN_ERR = sys_open_dir(folder);

#ifdef DEBUG
  printf("%d\n", SYS_OPEN_ERR);
#endif

  printf("Filename             Size\n");

  while(SYS_GET_ERR != ERR_SUP_NOENTR)
    {
      SYS_GET_ERR = sys_get_entry(buff, DISPLAY_BUFFER_SIZE, &file_size);

      if (SYS_GET_ERR != ERR_SUP_NOENTR)
	printf("%-20s %-10d\n", buff, file_size);
    }

  SYS_CLOSE_ERR = sys_close_dir();

  return 0;
}
